package com.suyi.service.impl;

import com.suyi.dao.TAccountDao;
import com.suyi.service.TAccountService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.concurrent.TimeUnit;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 贺袁晨
 * @since 2021-04-28
 */
@Service
public class TAccountServiceImpl implements TAccountService {

    private static final Logger LOGGER = LoggerFactory.getLogger(TAccountServiceImpl.class);

    @Autowired
    TAccountDao accountDao;

    /**
     * 扣减账户余额
     */
    @Override
    public void decrease(Long userId, BigDecimal money) {
        LOGGER.info("------->account-service中扣减账户余额开始");
        //模拟AccountServiceImpl添加超时
//        try {
//            TimeUnit.SECONDS.sleep(20);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        accountDao.decrease(userId,money);
        LOGGER.info("------->account-service中扣减账户余额结束");
    }
}
